import { createBrowserRouter } from "react-router-dom";
import Home from "../pages/Home";
import Layout from "../layouts/Layout";
import Category from "../pages/Category";
import Cart from "../pages/Cart";
import Mine from "@/pages/Mine";
import Search from "@/pages/package1/Search";
import GoodsDetail from "@/pages/package1/GoodsDetail";
import Address from "@/pages/Address";
import Login from "@/pages/Login";
import AuthRouter from "./AuthRouter";
import OrderList from "@/pages/package1/orderList";

const router = createBrowserRouter([
  {
    path: "/",
    element: <Layout />,
    children: [
      { index: true, element: <Home /> },
      { path: "category", element: <Category /> },
      {
        path: "cart",
        element: (
          <AuthRouter>
            <Cart />
          </AuthRouter>
        ),
      },
      { path: "mine", element: <Mine /> },
    ],
  },
  {
    path: "/search",
    element: (
      <AuthRouter>
        <Search />
      </AuthRouter>
    ),
  },
  {
    path: "/goodsDetail",
    element: (
      <AuthRouter>
        <GoodsDetail />
      </AuthRouter>
    ),
  },
  {
    path: "/address",
    element: (
      <AuthRouter>
        <Address />
      </AuthRouter>
    ),
  },
  {
    path: "/orderList",
    element: (
      <AuthRouter>
        <OrderList />
      </AuthRouter>
    ),
  },
  {
    path: "/login",
    element: <Login />,
  },
]);

export default router;
